﻿using MediatR;
using Traceability.App.Applications.Command.Enterprise;
using Traceability.Domain.Entity;
using Traceability.Domain.Repository;
using Traceability.Enum;

namespace Traceability.App.Applications.CommandHand.Enterprise
{
    public class EnterpriseshowCommandHand : IRequestHandler<EnterpriseshowCommand, ApiResult<EnterpriseModel>>
    {
        private readonly IBaseRepository<EnterpriseModel> _enter;

        public EnterpriseshowCommandHand(IBaseRepository<EnterpriseModel> enter)
        {
            _enter = enter;
        }

        public Task<ApiResult<EnterpriseModel>> Handle(EnterpriseshowCommand request, CancellationToken cancellationToken)
        {
            var result= new ApiResult<EnterpriseModel>();
            var enter = _enter.GetAll().FirstOrDefault(x=>x.Batch==request.Batch&&x.StepsType==request.Type);
            if (enter != null)
            {
                result.data = enter;

            }
           
            return Task.FromResult(result);
        }
    }
}
